//COPY panel to all pages
$(document).on('pagebeforecreate', '[data-role=page],[data-role="dialog"]', function (){
	if($(this).data('script')){
		(function (file) {
			var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true;
			script.src = file;
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(script, s);
		})($(this).data('script'));
	}
    
	var tst=$(this).find('.panel_right');
	if( tst.length <1 ) return;
	var panel=$('#theTmpl').html();
	tst.html(panel);
	tst.trigger( "updatelayout" );
});

var inited=false;
$( document ).on( "pageinit", "#page_home", function( event ) {
	if(!inited){
	  alert('INIT');
		 inited=true;
	}
});


$(document).on('pageshow', 'div[data-role*="page"],div[data-role*="dialog"]', function () {
     (function () {
        var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true;
        script.src = '/path/to/new/include.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(script, s);
    })();
});